package com.ustc.hewei.seckillmodule.config;

import com.ustc.hewei.commonmodule.entity.VoucherOrder;
import com.ustc.hewei.commonmodule.service.IVoucherOrderService;
import com.ustc.hewei.seckillmodule.serviceImpl.VoucherOrderServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.QueueBuilder;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author hewei
 * @version 1.0
 * @description: TODO
 * @date 2022/10/17 20:51
 */

@Component
public class OrderListener {

    private static final Logger logger = LoggerFactory.getLogger(OrderListener.class);

    @Resource
    private VoucherOrderServiceImpl voucherOrderService;

    @RabbitListener(queues = "voucherOrder")
    public void listenOrder(VoucherOrder order) {
        voucherOrderService.creatOrder(order);
        logger.info("订单 {}, 处理完成!", order.getId());
    }
}
